<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'AddRoom.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
<link rel="stylesheet" href="https://cdn.staticfile.org/foundation/5.5.3/css/foundation.min.css">
    <script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/foundation/5.5.3/js/foundation.min.js"></script>
    <script src="https://cdn.staticfile.org/foundation/5.5.3/js/vendor/modernizr.js"></script>
  </head>
<script type="text/javascript">
	function validateForm() {
    var x = document.forms["myForm"]["total"].value;
    var roomid=document.forms["myForm"]["roomid"].value;
    var type=document.forms["myForm"]["type"].value;
    var retNum = /^\d*$/;
    if (!retNum.test(x)||x == null || x == "") {
        alert("需要输入名字。");
        return false;
    }else if(x<1 || x >100 ){
    	alert("需要输入数字1-100");
        return false;
    }else if(roomid==null||roomid==""){
    	alert("请输入机房号");
    	return false;
    }else if(!retNum.test(roomid)){
    	alert("机房号只能是数字");
    	return false;
    }
    
    
    return true;
}


</script>
  
  <%
  String mid=(String)request.getAttribute("mid");
  String mname=(String)request.getAttribute("mname");
   %>
  
  <body style="background:url(images/back6.jpg);background-size:100% 100% ; background-attachment: fixed"
  style="padding:20px;">
  	<table align="center">
    <form name="myForm" action="servlet/CheckRoomServlet" onsubmit="return validateForm()" method="get">
  		<input type="hidden" name="op" value="add">
  		<input type="hidden" name="mid" value=<%=mid%>>
  		<input type="hidden" name="mname" value=<%=mname %>>
  		<br>
  		<tr>
   		<td align="center">机房号</td><td align="center"><input type="text" name="roomid" maxlength="6"  ></td>
   		</tr>
   		<tr>
   		<td>机房数</td><td><input type="text" name="total" maxlength="6" ></td>
   		</tr>
   		<tr><td></td>
   			<td>
		   		<select name="type">
					<option value="1">硬件教室</option>
					<option value="2">软件教室</option>   		
		   		</select>
   			</td>
   		</tr>
		<tr>
			<td>
	   		</td>
	   		<td>
	   		<input type="submit" value="添加">
	   		<a href="servlet/CheckRoomServlet?mid=<%=mid%>&mname=<%=mname%>">取消添加</a>	
	   		</td>
   		<tr>
   </form>
   </table>

    
    
    
  </body>
</html>
